<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/11/5
 * Time: 16:05
 */

namespace app\index\controller;


use app\common\lib\YopClient3;
use app\common\lib\YopRequest;
use think\Config;
use think\Controller;

class Yi extends Controller
{
    public function  get_pay(){
        $yeepay = Config::get('yeepay');
        $batchNo =  time(). rand(10000, 99999);
        $orderId =  "YOP_DF" . date("ymd_His") . rand(10, 99);
        $request = new YopRequest($yeepay['appKey'],$yeepay['private_key'],$yeepay['head_url'],$yeepay['yop_public_key']);
        $request->addParam("customerNumber", 10024438625);
        $request->addParam("groupNumber", 10024438625);
        $request->addParam("batchNo", $batchNo);
        $request->addParam("orderId",$orderId);
        $request->addParam("amount", 0.2);
        $request->addParam("accountName", '颜熹');
        $request->addParam("accountNumber", '6214832145480989');
        $request->addParam("bankCode", 'CMBCHINA');
        $request->addParam("feeType", 'SOURCE');
        $response = YopClient3::post("/rest/v1.0/balance/transfer_send", $request);
        if($response->validSign==1){
            echo "返回结果签名验证成功!\n";
        }
        //取得返回结果
        $data=self::object_array($response);

        return $data;
    }
    function object_array($array) {
        if(is_object($array)) {
            $array = (array)$array;
        } if(is_array($array)) {
            foreach($array as $key=>$value) {
                $array[$key] =self::object_array($value);
            }
        }
        return $array;
    }

}